import { loginAPI } from '@/api/user'
import { getToken, setToken, removeToken } from '@/utils/auth'
export default {
  namespaced: true,
  state: {
    token: getToken() || ''
  },
  mutations: {
    setToken(state, tk) {
      state.token = tk
      // localStorage.setItem('hmzj-token', tk)
      setToken(tk)
    },
    removeToken(state) {
      state.token = ''
      removeToken()
    }
  },
  actions: {
    async loginTk(store, formInfo) {
      const res = await loginAPI(formInfo)
      store.commit('setToken', res.data.token)
      // this.$message.success('登录成功')
    }
  },
  getters: {}
}
